/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mapping;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "dispositivo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dispositivo.findAll", query = "SELECT d FROM Dispositivo d"),
    @NamedQuery(name = "Dispositivo.findByIdDisp", query = "SELECT d FROM Dispositivo d WHERE d.idDisp = :idDisp"),
    @NamedQuery(name = "Dispositivo.findByNoserie", query = "SELECT d FROM Dispositivo d WHERE d.noserie = :noserie"),
    @NamedQuery(name = "Dispositivo.findByLocalizacion", query = "SELECT d FROM Dispositivo d WHERE d.localizacion = :localizacion"),
    @NamedQuery(name = "Dispositivo.findByEstado", query = "SELECT d FROM Dispositivo d WHERE d.estado = :estado")})
public class Dispositivo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idDisp")
    private String idDisp;
    @Column(name = "noserie")
    private String noserie;
    @Column(name = "localizacion")
    private String localizacion;
    @Column(name = "estado")
    private String estado;
    @JoinTable(name = "disp_asoc", joinColumns = {
        @JoinColumn(name = "hijo", referencedColumnName = "idDisp")}, inverseJoinColumns = {
        @JoinColumn(name = "padre", referencedColumnName = "idDisp")})
    @ManyToMany
    private Collection<Dispositivo> dispositivoCollection;
    @ManyToMany(mappedBy = "dispositivoCollection")
    private Collection<Dispositivo> dispositivoCollection1;
    @ManyToMany(mappedBy = "dispositivoCollection")
    private Collection<Software> softwareCollection;
    @JoinTable(name = "depa_disp", joinColumns = {
        @JoinColumn(name = "idDisp", referencedColumnName = "idDisp")}, inverseJoinColumns = {
        @JoinColumn(name = "idDepartamento", referencedColumnName = "idDepartamento")})
    @ManyToMany
    private Collection<Departamento> departamentoCollection;
    @ManyToMany(mappedBy = "dispositivoCollection")
    private Collection<Empleado> empleadoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idDisp")
    private Collection<DetallesRed> detallesRedCollection;
    @OneToMany(mappedBy = "idDispositivo")
    private Collection<Ticket> ticketCollection;
    @JoinColumn(name = "idModelo", referencedColumnName = "idModelo")
    @ManyToOne(optional = false)
    private Modelo idModelo;
    @OneToMany(mappedBy = "idDispActual")
    private Collection<Componentes> componentesCollection;
    @OneToMany(mappedBy = "idDispOrigen")
    private Collection<Componentes> componentesCollection1;

    public Dispositivo() {
    }

    public Dispositivo(String idDisp) {
        this.idDisp = idDisp;
    }

    public String getIdDisp() {
        return idDisp;
    }

    public void setIdDisp(String idDisp) {
        this.idDisp = idDisp;
    }

    public String getNoserie() {
        return noserie;
    }

    public void setNoserie(String noserie) {
        this.noserie = noserie;
    }

    public String getLocalizacion() {
        return localizacion;
    }

    public void setLocalizacion(String localizacion) {
        this.localizacion = localizacion;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<Dispositivo> getDispositivoCollection() {
        return dispositivoCollection;
    }

    public void setDispositivoCollection(Collection<Dispositivo> dispositivoCollection) {
        this.dispositivoCollection = dispositivoCollection;
    }

    @XmlTransient
    public Collection<Dispositivo> getDispositivoCollection1() {
        return dispositivoCollection1;
    }

    public void setDispositivoCollection1(Collection<Dispositivo> dispositivoCollection1) {
        this.dispositivoCollection1 = dispositivoCollection1;
    }

    @XmlTransient
    public Collection<Software> getSoftwareCollection() {
        return softwareCollection;
    }

    public void setSoftwareCollection(Collection<Software> softwareCollection) {
        this.softwareCollection = softwareCollection;
    }

    @XmlTransient
    public Collection<Departamento> getDepartamentoCollection() {
        return departamentoCollection;
    }

    public void setDepartamentoCollection(Collection<Departamento> departamentoCollection) {
        this.departamentoCollection = departamentoCollection;
    }

    @XmlTransient
    public Collection<Empleado> getEmpleadoCollection() {
        return empleadoCollection;
    }

    public void setEmpleadoCollection(Collection<Empleado> empleadoCollection) {
        this.empleadoCollection = empleadoCollection;
    }

    @XmlTransient
    public Collection<DetallesRed> getDetallesRedCollection() {
        return detallesRedCollection;
    }

    public void setDetallesRedCollection(Collection<DetallesRed> detallesRedCollection) {
        this.detallesRedCollection = detallesRedCollection;
    }

    @XmlTransient
    public Collection<Ticket> getTicketCollection() {
        return ticketCollection;
    }

    public void setTicketCollection(Collection<Ticket> ticketCollection) {
        this.ticketCollection = ticketCollection;
    }

    public Modelo getIdModelo() {
        return idModelo;
    }

    public void setIdModelo(Modelo idModelo) {
        this.idModelo = idModelo;
    }

    @XmlTransient
    public Collection<Componentes> getComponentesCollection() {
        return componentesCollection;
    }

    public void setComponentesCollection(Collection<Componentes> componentesCollection) {
        this.componentesCollection = componentesCollection;
    }

    @XmlTransient
    public Collection<Componentes> getComponentesCollection1() {
        return componentesCollection1;
    }

    public void setComponentesCollection1(Collection<Componentes> componentesCollection1) {
        this.componentesCollection1 = componentesCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDisp != null ? idDisp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dispositivo)) {
            return false;
        }
        Dispositivo other = (Dispositivo) object;
        if ((this.idDisp == null && other.idDisp != null) || (this.idDisp != null && !this.idDisp.equals(other.idDisp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mapping.Dispositivo[ idDisp=" + idDisp + " ]";
    }
    
}
